<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h1>聊天室</h1>

  <script>
    var ws = new WebSocket("ws://127.0.0.1:8080")


    ws.onopen = () => {
      console.log('连接成功')
    }

    ws.onmessage = (val) => {
      console.log(val)
    }

    ws.onerror = (err) => {
      console.error(err)
    }

  </script>
</body>
</html>